package com.neutech.controller;

import com.neutech.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class DepartmentController {


    /*******************科室___START*************************/
    @Autowired
    private DepartmentService departmentService;
    @RequestMapping("/queryDepartment")
    public List<Map<String,Object>> getDepartment(){
        return departmentService.queryDepartment();
    }
    @RequestMapping("/insertDepartment")
    public void insDepartment(@RequestParam Map  map){
//        System.out.println("看这里！");
//        System.out.println(map.get("depid"));
        map.put("number",0);
        departmentService.insertDepartment(map);
    }
    @RequestMapping("/deleteDepartment")
    public void delDepartment(@RequestParam Map  map){
        departmentService.deleteDepartment(map);
        //System.out.println(map.get("depid"));
    }
    @RequestMapping("/updataDepartment")
    public void updDepartment(@RequestParam Map  map){
        System.out.println("看这里");
        System.out.println(map);
        System.out.println("看这里");
        Map<String,Object> map2 = new HashMap<>();
        map2.put("depid",map.get("depid"));
        map2.put("name",map.get("name"));
        map2.put("deptype",map.get("deptype"));
        map2.put("number",map.get("number"));
        System.out.println(map2);
        departmentService.updataDepartment(map2);
    }
    /**************************END*******************************/

}
